# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Maintainer: Jan de Groot <jgc@archlinux.org>

pkgbase=gst-plugins-base
pkgname=(gst-plugins-base-libs gst-plugins-base)
pkgver=1.14.4
pkgrel=1
pkgdesc="GStreamer Multimedia Framework Base Plugins"
url="https://gstreamer.freedesktop.org/"
arch=(x86_64)
license=(LGPL)
depends=(gstreamer orc libxv iso-codes libgudev mesa)
makedepends=(alsa-lib cdparanoia libvisual libvorbis libtheora pango opus graphene libpng libjpeg
             gobject-introspection gtk-doc autoconf-archive git)
checkdepends=(gtk3 qt5-base clutter sdl glu)
options=(!emptydirs)
_commit=384ff7d0268c71e76f7328a9ca6dfe96e4a3ab23  # tags/1.14.4^0
source=("git+https://anongit.freedesktop.org/git/gstreamer/gst-plugins-base#commit=$_commit"
        "gst-common::git+https://anongit.freedesktop.org/git/gstreamer/common")
sha256sums=('SKIP'
            'SKIP')

pkgver() {
  cd $pkgbase
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd $pkgbase

  git submodule init
  git config --local submodule.common.url "$srcdir/gst-common"
  git submodule update

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd $pkgbase
  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --libexecdir=/usr/lib \
    --with-package-name="GStreamer Base Plugins (Arch Linux)" \
    --with-package-origin="https://www.archlinux.org/" \
    --enable-experimental \
    --enable-gtk-doc \
    --disable-static
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd $pkgbase
  # GL tests need hardware
  make check || :
}

package_gst-plugins-base-libs() {
  pkgdesc="${pkgdesc/Plugins/Libraries}"

  cd $pkgbase
  make DESTDIR="$pkgdir" install
  make -C ext DESTDIR="$pkgdir" uninstall
}

package_gst-plugins-base() {
  depends=("gst-plugins-base-libs=$pkgver"
           alsa-lib cdparanoia libvisual libvorbis libtheora pango opus graphene libpng libjpeg)

  cd $pkgbase
  make -C gst-libs DESTDIR="$pkgdir" install
  make -C ext DESTDIR="$pkgdir" install
  make -C gst-libs DESTDIR="$pkgdir" uninstall
}
